﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Travel.Data.Dtos.TravelBusiness;
using Travel.Data.Entity;
using Travel.Data.Inputs;

namespace Travel.Data.Profiles
{
    /// <summary>
    ///  旅游相关的AutoMap映射
    /// </summary>
    public class TravelProfile :Profile
    {
        public TravelProfile()
        {
            CreateMap<TabCategory, CategoryDto>().ForMember(p => p.UpdatedUserName, opt => opt.MapFrom(src => src.UpdatedUser.Nickname));

            CreateMap<CategoryInput, TabCategory>().ForMember(c => c.UpdatedUserId, opt => opt.MapFrom(src => src.LoginUserId)).ForMember(c => c.CreatedUserId, opt => opt.MapFrom(src => src.LoginUserId));

            CreateMap<TabTravel, TravelDto>().ForMember(p=>p.CategoryName,opt=>opt.MapFrom(src=>src.Category.CategoryName));
            CreateMap<TabTravel, TravelDetailDto>().ForMember(c=>c.CategoryName,p=>p.MapFrom(s=>s.Category.CategoryName));
            CreateMap<TabTravelImg,TravelImageDto>();

            CreateMap<TravelAddOrUpdateInput, TabTravel>().ForMember(c => c.CreatedUserId, c => c.MapFrom(s => s.LoginUserId)).ForMember(c => c.UpdatedUserId, c => c.MapFrom(s => s.LoginUserId));

            CreateMap<TravelImageInput, TabTravelImg>();

            CreateMap<TravelUserDto,TabUser>().ReverseMap();
            //设置领队
            CreateMap<TabTravelLeader, LeaderUserDto>();
        }
    }
}
